﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Bam
{
    
    class Screen_Splash : Screen
    {
        public delegate  void LOAD_FUNC_PTR();
        public List<LOAD_FUNC_PTR> load_funcs;
        public int current_step;
        String whats_loading;
        public Screen_Splash()
        {
            current_step = 0;
            load_funcs = new List<LOAD_FUNC_PTR>();
            load_funcs.Add(load_images);
            load_funcs.Add(load_controls);
        }
        public void load_images()
        {
            whats_loading = "Images";
        }
        public void load_controls()
        {
            whats_loading = "Controls";
            //check to see what controller is connceted
            GamePad.GetState(PlayerIndex);

        }
        public override void render()
        {
            String percent;
            percent = String.Concat(((float)current_step / (float)load_funcs.Count) * 100);
            percent += "%";
            globals.drawText(percent,0,0,Color.AntiqueWhite);
            globals.drawText("loading: " + whats_loading, 0, 50, Color.AntiqueWhite);  
            
        }
        public override void update()
        {
            if (current_step == load_funcs.Count)
                return;
            LOAD_FUNC_PTR func = new LOAD_FUNC_PTR(load_funcs[current_step]);
            func();
            current_step++;
        }
        public override void  handle_input()
        {
            
        }
        public override SCREEN_STATE go_to_state()
        {
            //check if everything is loaded
            if (current_step == load_funcs.Count)
            {
                return SCREEN_STATE.main_menu;
            }
            else
                return SCREEN_STATE.none;
               
        }
    }
}
